package com.jdbcDome;

import java.sql.*;

public class JdbcDome {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //获取mysql链接对象
        Connection connection = DriverManager.getConnection("jdbc:mysql:///db14","root","root");
        //创建SQL对象
        Statement statement = connection.createStatement();
        //执行sql语句
        ResultSet resultSet = statement.executeQuery("SELECT *from student");
        //获取表里面的元素
        while (resultSet.next()){
            int id = resultSet.getInt("sid");
            String name = resultSet.getString("name");
            int age = resultSet.getInt("age");
            Date birthday = resultSet.getDate("birthday");
            System.out.println(id+"===="+name+"===="+age+"===="+birthday);
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}
